Expand description
A Rust library for generating random and pseudo-random numbers based on the Mersenne Twister algorithm
Overview
This crate provides a random number generator based on the Mersenne Twister algorithm. The Mersenne Twister algorithm is a pseudorandom number generator (PRNG) developed by Makoto Matsumoto and Takuji Nishimura in 1997. It is based on a linear feedback shift register (LFSR) and is designed to have a period of 2^19937-1. It is one of the most widely used PRNGs in scientific computing.
Features
- Pseudorandom number generation: The library uses the Mersenne Twister algorithm (MT19937) to generate pseudorandom integers uniformly distributed in 0 to (2^32 - 1) using an array of unsigned 32-bit integers and an index.
- Random number types: The library provides several methods to generate different types of random numbers including bool, bytes, char, float, and int.
- Range of values: The methods for generating random numbers allow the user to specify the range of values for the output.
- Random element selection: The library provides a method to choose a random element from a given slice of values.
- Initialization: The library provides a new() method to create a new instance of the random number generator.
- Optimization: The library is optimized for performance with the number of elements in the array set to 624 and the number of elements to skip set to 397.
- Constant values: The library uses several constant values in the Mersenne Twister algorithm including MATRIX_A, UPPER_MASK, LOWER_MASK, TEMPERING_MASK_B, and TEMPERING_MASK_C.
Structs
The Random struct is used to generate random numbers using the
Mersenne Twister algorithm. It generates pseudorandom integers
uniformly distributed in 0..(2^32 - 1) starting from any odd seed in
0..(2^32 - 1).